#include "funcs.h"
#include "String.h"
#include <CommDlg.h>
#include "CeleLib/CeleCtrl.h"

BOOL SetMenu(HWND hWnd, UINT MB_Res)
{
	SHMENUBARINFO mbi;
	
	memset(&mbi, 0, sizeof(SHMENUBARINFO));   
	mbi.cbSize   = sizeof(SHMENUBARINFO);
	mbi.hwndParent   = hWnd;      // Menu bar's owner
	mbi.nToolBarId   = MB_Res; // Menu bar resource
	mbi.hInstRes   = g_hInst;     //HINST in which resource is located
	
	//Create the Menu Bar
	if(!SHCreateMenuBar(&mbi))
	{
		return FALSE;
	}
	
	HWND hMenuBar = mbi.hwndMB;
	//Override the Back key
	SendMessage(hMenuBar, SHCMBM_OVERRIDEKEY, VK_TBACK, 
		MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
	return TRUE;
}

BOOL SetMenuItemState(HWND hMenuBar, UINT MB_ID, BYTE bState)
{
	TBBUTTONINFO tb;
	tb.cbSize = sizeof(TBBUTTONINFO);
	tb.dwMask = _MBIF(TBIF_STATE);
	tb.fsState = bState;
	return SendMessage(hMenuBar, TB_SETBUTTONINFO, MB_ID , (LPARAM) &tb);
}

TStr GetAppPath()
{
	TStr Path(MAX_PATH);
	if (GetModuleFileName(g_hInst, *Path, MAX_PATH))
	{
		return Path;
	}
	return L"";
}

